package com.baicaoyuan.web.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

@RequiredArgsConstructor
@Getter
public enum CashOutStatusEnum {


    /**
     * 申请中
     */
    COMMIT("0"),

    /**
     * 拒绝
     */
    REJECT("9"),

    /**
     * 成功
     */
    SUCCESS("1");

    private final String status;

    /**
     * 根据标识获取枚举
     *
     * @param applyStatus
     * @return
     */
    public static CashOutStatusEnum acquire(final String applyStatus) {
        Optional<CashOutStatusEnum> statusEnum = Arrays.stream(CashOutStatusEnum.values())
                .filter(s -> (Objects.equals(s.getStatus(), applyStatus)))
                .findFirst();
        return statusEnum.orElse(CashOutStatusEnum.COMMIT);
    }
}
